package install.ren.exercise.test.thread;

import java.util.Optional;
import java.util.concurrent.TransferQueue;

public class Consumer<T> {

    private TransferQueue<T> transferQueue;

    public Optional<T> get(){
        try {
            T o = transferQueue.take();
            return Optional.ofNullable(o);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return Optional.empty();
    }

    public void setTransferQueue(TransferQueue transferQueue){
        this.transferQueue = transferQueue;
    }
}
